﻿@{
    ViewBag.Title = "产品列表";
    Layout = "~/Areas/Shared/_spListV1.cshtml";
    ViewBag.ListActionURL = Url.Action("ProductList", "ProductManage", new { area = "Cubic" });
    ViewBag.AddActionURL = Url.Action("AddProduct", "ProductManage", new { area = "Cubic" });
    ViewBag.DelActionURL = Url.Action("DelProduct", "ProductManage", new { area = "Cubic" });
    ViewBag.EditActionURL = Url.Action("EditProduct", "ProductManage", new { area = "Cubic" });
    ViewBag.IdColumn = "ProductId";
    ViewBag.NameColumn = "ProductName";
    ViewBag.ListSortName = "";
    ViewBag.ListSortOrder = "";
    ViewBag.AddWindowTitle = "添加产品";
    ViewBag.EditWindowTitle = "编辑产品";   
}
@model Kaiser.Modules.Cubic.DomainModel.Product.ProductDetail
@section Script
{
    <script type="text/javascript">

        config.GridOption.toolbar = "#tb";
        config.GridOption.singleSelect = true;
        config.GridOption.columns = [[
            { field: 'ProductCode', title: '产品编号', width: 100, sortable: true },
            { field: 'ProductName', title: '产品名称', width: 150, sortable: true },
            { field: 'ProductEnglishName', title: '产品英文名称', width: 150, sortable: true },
            { field: 'FileNum', title: '附件数', width: 20, sortable: true },
            { field: 'LastModifyUserFullName', title: '更新人', width: 40, sortable: true },
            { field: 'LastModifyDateTime', title: '更新时间', width: 40, sortable: true, formatter: Common.DateTimeFormatter },
            {
                field: '操作',
                title: '操作',
                width: 60,
                formatter: function (value, row, rowIndex) {
                    var arr = new Array();
                    arr.push('<a href=# class="OpertaionButton"  onclick=SetPhoto("' + rowIndex + '")>[设置图片]</a>');
                    arr.push('<a href=# class="OpertaionButton"  onclick=EditItem("' + rowIndex + '")>[编辑]</a>');

                    arr.push('<a href=# class="OpertaionButton"  onclick=del("' + row.@ViewBag.IdColumn + '")>[删除]</a>');
                    return arr.join('');
                }
            }
        
        ]];

 
    </script>
}
<div data-options="region:'west',split:true" title="分类" style="width: 200px;">
    <ul class="easyui-tree" id="ProductTree">
    </ul>
</div>

<div id="tb"  >
    <div  >
        <div style="float: left">
         <a href="#" class="easyui-linkbutton" style="margin-top: 4px" iconcls="icon-add" plain="true">新增</a>         
        </div>
        <div  style="float: left">
            <form method="post" id="QuickSearch" class="quickSearch">
                <table>
                    <tr>
                        <td>
                            产品名称： @Html.TextBox("ProductName")
                            @Html.Hidden("CategoryId")
                        </td>
                        <td>
                            <a href="#" class="easyui-linkbutton" iconcls="icon-search" onclick="Search()">查询</a>
                        </td>
                    </tr>
                </table>
            </form>
        </div>
        <div style="clear: left"></div>
    </div>
    <div style="margin-bottom: 5px">
   
    </div>
</div>
<script type="text/javascript">
    var categoryId = '';
    function Search() {        
        var sf = $("#QuickSearch").serializeJson();
        //alert(sf);
        grid.datagrid({ url: virpath + config.ListActionURL, queryParams: sf });
    }
    $("#QuickSearch input").keyup(function (event) {
        if (event.keyCode == 13) Search();
    });

    function SetPhoto(rowIndex) {
        stopPropagation();
        var rows = grid.datagrid('getRows');
        var row = rows[rowIndex];
        var url = '@Url.Action("ProductPhotoList","ProductManage",new {area="Cubic"})?ProductId='+row.ProductId;
        
        
        var dialog = parent.openWindow({
            title: "产品图片管理",
            url: url,
            height: 600,
            width: 800,
            isIframe: true,
            maximizable: true,                
        });
    }
    
    $(function () {
        

        $('#ProductTree').tree({
            url: '@Url.Action("GetCategoryTree", "ProductCategoryManage", new { area = "Cubic", Code = "0" })',
            onClick: function (node) {
                //categoryId = node.id;
                config.AddActionURL = '@Url.Action("AddProduct", "ProductManage", new { area = "Cubic" })?categoryId=' + node.id;
                grid.datagrid({ url: config.ListActionURL, queryParams: { CategoryId: node.id } });

            },
            onLoadSuccess: function () {
                var node = $('#ProductTree').tree('find', $("#Code").val());
                if (node != null) {
                    $('#ProductTree').tree('select', node.target);
                }

            }
        });

    });

 

   
</script>
